﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            Human h1 = new Human
            {
                FirstName = "Вася",
                LastName = "Пупкин",
                Age = 100

            };
            Human h2 = new Human
            {
                FirstName = "Иван",
                LastName = "Иванов",
                Age = 15
            };

            List<Human> hList = new List<Human>();
            hList.Add(h1);
            hList.Add(h2);
            hList.Sort();

            //foreach (var item in hList)
            //{
            //    Console.WriteLine(item.FirstName+" "+item.LastName); 
            //}

            string[] strArray = new string[]
            {
                "Башот",
                "Ашот",
                "Ваншот"
            };
            CustomStringComparer cSC = new CustomStringComparer();
            //Array.Sort(strArray);
            Array.Sort(strArray, cSC);
            foreach (var item in strArray)
            {
                Console.WriteLine(item);
            }
        }
    }
    class Human : IComparable<Human>
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }

        public int CompareTo(Human other)
        {
            if (this.Age < other.Age) return 1;
            else if (this.Age == other.Age) return 0;
            else return -1;
        }

    }
    class CustomStringComparer : IComparer<string>
    {
        public int Compare(string x, string y)
        {
            if (x.Length < y.Length) return 1;
            else if (x.Length == y.Length) return 0;
            else return -1;
        }
    }
}
